home *** CD-ROM | disk | FTP | other *** search
/ CD Ware Multimedia 1995 May / cd Ware (Juegos) Epimundo.iso / DOS / C / COP.ZIP / SHAPE.CPP < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-21  |  1.0 KB  |  53 lines

  1. #include <stdarg.h>
  2. #include "shape.hpp"
  3.  
  4. Segment::Segment(unsigned x, unsigned y,
  5.     unsigned shapeCount, ...)
  6.     : Shape(x,y)
  7. {
  8.     va_list shapes;
  9.     unsigned j;
  10.  
  11.     this->shapes = (Shape **) 0;
  12.     this->shapeCount = 0;
  13.     if (shapeCount)
  14.        if ((this->shapes = new Shape *[shapeCount])
  15.           != (Shape **)0)  {
  16.           va_start(shapes,shapeCount);
  17.           for (j = 0; j < shapeCount; j++)
  18.         this->shapes[j] =
  19.         va_arg(shapes,Shape *);
  20.           va_end(shapes);
  21.           this->shapeCount = shapeCount;
  22.        }
  23.        else  {
  24.           va_start(shapes,shapeCount);
  25.           for (j = 0; j < shapeCount; j++)
  26.             delete va_arg(shapes,Shape *);
  27.           va_end(shapes);
  28.        }
  29. }
  30.  
  31. void Segment::show(int xxpose, int yxpose,
  32.     unsigned scale)
  33. {
  34.     unsigned j;
  35.  
  36.     if (shapeCount)
  37.        for (j = 0; j < shapeCount; j++)
  38.           if (shapes[j])
  39.              shapes[j]->show((int)getx()+xxpose,
  40.             (int)gety()+yxpose,scale);
  41. }
  42.  
  43. Segment::~Segment()
  44. {
  45.     unsigned j;
  46.  
  47.     if (shapeCount)  {
  48.        for (j = 0; j < shapeCount; j++)
  49.         delete shapes[j];
  50.        delete shapes;
  51.     }
  52. }
  53.